08. Packages Overview Quiz

Packages Quiz

(All solutions can be downloaded using link at bottom of page.)

Which of the following are true statements about Python packages?

SOLUTION:
  • You can add functions and classes to your code by importing a package
  • Packages are a collection of modules, or Python files, that people wrote
  • You can simplify and optimize many tasks using packages

Is this a correct way to use a function from a package?

import some_package as sp
do_something()
SOLUTION: No

Is this a correct way to use a function from a package?

import some_package as sp
sp.do_something()
SOLUTION: Yes

Is this a correct way to use a function from a package?

import some_package as sp
some_package.do_something()
SOLUTION: No

Is this a correct way to use a function from a package?

import some_package
some_package.do_something()
SOLUTION: Yes

Is this a correct way to use a function from a package?

import some_package as randomlongaliasthatmakesnosense
randomlongaliasthatmakesnosense.do_something()
SOLUTION: No

If you're stuck on an error using a new package, what are ways you can solve the problem?

SOLUTION:
  • Google the issue
  • Read the documentation for that function
  • Check stack overflow for similar errors/problems
  • Ask someone